﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VisualPoint.Controls.ViewModels;

namespace VisualPoint.Controls.Views
{
    /// <summary>
    /// Interaction logic for WindowsConfigurationsWindow.xaml
    /// </summary>
    public partial class WindowsConfigurationsWindow : Window
    {
        private WindowsConfigurationsViewModel ViewModel;

        public WindowsConfigurationsWindow()
        {
            InitializeComponent();

            ViewModel = new WindowsConfigurationsViewModel();
            DataContext = ViewModel;
            ViewModel.Initialize();
        }

        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            Close();
        }

        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.Delete();
        }

        private void Create_Click(object sender, RoutedEventArgs e)
        {
            WindowsConfigurationWindow window = new WindowsConfigurationWindow();
            window.Owner = this;
            bool? returnCode = window.ShowDialog();
            if (returnCode.HasValue
                && returnCode.Value)
            {
                string value = window.ConfigurationName;

                ViewModel.Create(value);
            }
        }

        private void Update_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.Update();
        }
    }
}
